#
# Military Bases Mod
# CvMilitaryBasesEventManager
#
# < edited by the ViSa Modpack Team >

from CvPythonExtensions import *
import CvUtil

import CvEventManager
import sys
import PyHelpers
import CvMainInterface
import CvViSaGameUtils
import CvConfigParser
import CvActionButtonUtils

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
CvActionButtonUtils = CvActionButtonUtils.CvActionButtonUtils()


"""
# Increase or decrease this value to change the amount great statesmen improve 
# diplomatic relations between their civilization and another civilization.
# Default value is 5
g_iDiplomaticRelationsImprovementAmount = 5

# Change this to have the legal civic option bureaucracy give free statemen to 
# civilizations that have the legal civic option bureaucracy set. The free 
# statesmen are added to the civilization's capital city.
# Default value is true
g_bBureaucracyCivicAddsStatesmen = true

# Change this to increase or decrease the number of free statesmen that are 
# added to a civilization's capital city if they select bureaucracy as their 
# legal civic option.
# Default value is 2
g_iBureaucracyStatesmanBonus = 2
"""
# globals
###################################################
class CvMilitaryBasesEventManager:
	def __init__(self, eventManager):
		# initialize base class
		"""		
		global g_iDiplomaticRelationsImprovementAmount
		global g_bBureaucracyCivicAddsStatesmen
		global g_iBureaucracyStatesmanBonus 

		config = CvConfigParser.CvConfigParser("Great Statesman Config.ini")
		
		# Read the configuration values for the great statesman
		if(config != None):
			g_iDiplomaticRelationsImprovementAmount = config.getint("Great Statesman", "Diplomatic Relations Improvement Amount", 5)
			g_bBureaucracyCivicAddsStatesmen = config.getboolean("Great Statesman", "Bureaucracy Civic Adds Statesmen", true)
			g_iBureaucracyStatesmanBonus = config.getint("Great Statesman", "Bureaucracy Statesman Bonus", 2)
		"""			
		eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn)
		#eventManager.addEventHandler("mouseEvent", self.onMouseEvent)


	def onMouseEvent(self, argsList):

		CyInterface().addImmediateMessage("%s" %(CvActionButtonUtils.canTrainUnit(gc.getPlayer(0).getCapitalCity().plot().getUnit(0))),"")

	def onCityDoTurn(self, argsList):
		'City Production'
		objCity = argsList[0]
		iPlayer = argsList[1]

		# Go through each unit in the city, see if the unit is training, try to give them XP
		CvActionButtonUtils.trainCityUnits(objCity)
		
		
